package com.ljy.system.marvel_sys.common.shiro.session;

import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.CachingSessionDAO;

import java.io.Serializable;
import java.util.UUID;

/**
 * @version 1.0.0
 * @ClassName: ShiroSessionDAO
 * @Description: 自定义shiro会话管理
 * @author: LiJunYi
 * @create: 2020/4/12 20:26
 */
public class ShiroSessionDAO extends CachingSessionDAO {

    public ShiroSessionDAO(CacheManager cacheManager)
    {
        // 注入缓存管理器
        setCacheManager(cacheManager);
    }

    @Override
    protected Serializable doCreate(Session session) {
        Serializable sessionId = UUID.randomUUID().toString().replace("-","").toUpperCase();
        assignSessionId(session, sessionId);
        return sessionId;
    }

    @Override
    protected Session doReadSession(Serializable sessionId) {
        return null;
    }

    @Override
    protected void doUpdate(Session session) {

    }

    @Override
    protected void doDelete(Session session) {

    }

}
